<?php
/*
*   文章列表页
*/
  get_header();
  if(have_posts()):the_post();
  $cat= single_cat_title('', false);
  $cat_id=get_cat_ID($cat);  
  
  get_sidebar('pagenav'); //调用页面导航
?>
 <?php /*?>
<!--
  <div class="pinpaiMenu po_r swiper-container">
        <ul class="menuScroll_lists  po_a cf swiper-wrapper">
          <li class="swiper-slide"><a href="/" >首页<em></em></a></li>
        <?php
            foreach (array_reverse(get_categories()) as $key => $value) {				//限制优化栏目显示
        ?>			
			<?php 				
				if($value->slug!="seoart"){	
			?>					
					<li class="swiper-slide <?php if($value->term_id == $cat_id){echo 'active';}?>">
						<a href="<?php echo get_category_link((int)$value->term_id);?>" >
							<?php echo $value->name;?><em></em>
						</a>
					</li>										
		<?php
				}
            }
		?>
        </ul>
  </div>
  -->
   <?php */?>
	<div class="listNews po_r">
      <?php
        $paged_view = $_GET['paged_view']?$_GET['paged_view']:1;//判断是否首次加载页面
        $args=array(
          'post_type' => 'post',
          'tax_query' => array(
            array(
            'taxonomy' => 'category',
            'field' => 'id',
            'terms' => array($cat_id)
              )
          ),
          'meta_key' => 'rank',
          'orderby'  => array('meta_value_num' => 'DESC', 'date' => 'DESC'),
          'posts_per_page' =>8,
          'paged' =>$paged_view
        );
        $query = new WP_Query($args);
        while($query->have_posts()):$query->the_post();
          $img_url = get_field('img')?get_field('img'):get_template_directory_uri().'/images/default.jpg';
      ?>
      <div class="listNewsContent">
        <div class="litpic"><a href="<?php the_permalink();?>"><img src="<?php echo $img_url;?>" /></a></div>
        <div class="newsContent">
            <h2 class="infooneline"><a href="<?php the_permalink();?>"><?php the_title();?></a></h2>
            <p class="infomoreline"><a href="<?php the_permalink();?>"><?php echo mb_strimwidth(strip_tags(get_the_content()),0,72,'...');?></a></p>
        </div>
      </div>
      <?php
        endwhile;
        wp_reset_query();
      ?>
  </div>
  <div style="clear:both;"></div>
  <div class="post_next">加载更多</div>

<script type="text/javascript">
jQuery(document).ready(function($) {
  //点击下一页的链接(即那个a标签)   
  var paged_view=2;
  $('.post_next').click( function() {   
    $this = $(this);
    $this.html("Loading...");
    $.ajax( { //发起ajax请求   
        url: "?action=json&paged_view="+paged_view, //请求的地址就是下一页的链接   
        type: "get", //请求类型是get   
     error: function(request) {   
         //如果发生错误怎么处理   
     },   
     success: function(data) { //请求成功
        if(paged_view<=<?php echo $query->max_num_pages;?>){
          var $res = $(data).find(".listNewsContent"); //从数据中挑出文章数据，请根据实际情况更改   
          $('.listNews').append($res); //将数据加载加进posts-loop的标签中。
          $this.html("加载更多");
          paged_view++;
        }else{
          $('.post_next').html("没有更多内容了");
        }
     }   
     });  
   });      
 });  
</script>
<?php
  endif;
  get_footer();
?>
<!--123123-->